<template>
    <view class="giantScreen" :style="{'padding-top':`${clientRect.top}px`}">
        <div class="bg background--custom"></div>
        <div class="head" :style="{height:`${clientRect.height}px`}">
            <div class="left" :style="{left:`${clientRect.right}px`}">
                <text @click="handleSetting" class="cuIcon-settingsfill"></text>
            </div>
            <div class="title">قۇندۇز كىنوخانسى</div>
        </div>
        <div class="body">
            <div class="userinfo-no-login" v-if="!userInfo.id">
                <view class="avatar">
                    <image class="img" src="/static/img/icon/man.svg"></image>
                </view>
                <view class="loginBtn">كىرىش</view>
            </div>
            <div class="userinfo-yes-login" v-if="userInfo.id">
                <div class="left">
                    <div class="name">{{userInfo.username}}</div>
                    <div class="info">
                        <div class="id">
                            <text>ID</text>
                            <text class="margin-xs ">:</text>
                            <text>{{userInfo.id}}</text>
                        </div>
                        <view class="center">|</view>
                        <view class="tip">
                            <view class="cuIcon-selection font"></view>
                            <view class="vip">
                                {{!userInfo.vip_time>0? 'ئادەتتكى ئەزا':'ئالى ئەزا'}}
                            </view>
                        </view>
                    </div>
                </div>
                <div class="right">
                    <view class="avatar" @click="handleSetting">
                        <image class="img" :src="userInfo.useravatar" mode="aspectFill"></image>
                    </view>
                </div>
            </div>
        </div>
        <div class="foot">
            <div class="box">
                <div class="item" @click="handleCoin">
                    <div class="icon">
                        <image class="img" src="/static/images/Yoqlima.svg" mode="widthFix"></image>
                    </div>
                    <div class="text">
                        يوقىلما
                    </div>
                </div>
                <div class="item" @click="handleAgent">
                    <div class="icon">
                        <image class="img" src="/static/images/Wakalatqi.svg" mode="widthFix"></image>
                    </div>
                    <div class="text">
                        ۋاكالەتچى بولۇش
                    </div>
                </div>
                <div class="item" @click="handleVip">
                    <div class="icon">
                        <image class="img" src="/static/images/Alax.svg" mode="widthFix"></image>
                    </div>
                    <div class="text">
                        ئالى ئەزا مەركىزى
                    </div>
                </div>
            </div>
        </div>
    </view>
</template>

<script>
    import {
        height,
        top,
        right,
    } from '@/scripts/compatible/clientRect.js'
    export default {
        props: {
            userInfo: {
                type: Object,
                require: true
            },
        },
        data() {
            return {
                clientRect: {
                    height: 32,
                    top: 24,
                    right: 8,
                },
            }
        },
        mounted() {
            this.clientRect_init()
        },
        methods: {
            handleVip() {
                uni.navigateTo({
                    url: '/pages/vip/index'
                })
            },
            handleAgent() {
                uni.navigateTo({
                    url: '/pages/agent/index'
                })
            },
            handleCoin() {
                uni.navigateTo({
                    url: '/pages/coin/index'
                })
            },
            handleSetting() {
                uni.navigateTo({
                    url: '/pages/setting/index'
                })
            },
            clientRect_init() {
                this.clientRect = {
                    height,
                    top,
                    right,
                }
            },
        },
    }
</script>

<style lang="scss" scoped>
    .giantScreen {
        position: relative;

        .bg {
            position: absolute;
            z-index: -1;
            top: 0;
            width: 150%;
            left: -25%;
            height: 300px;
            border-radius: 0 0 50% 50%;
        }

        .head {
            color: #fff;
            position: relative;

            .title {
                position: absolute;
                left: 0;
                right: 0;
                margin: auto;
                width: max-content;
                height: 32px;
                display: flex;
                align-items: center;
                font-size: 16px;
            }

            .left {
                position: absolute;
                top: 0;
                bottom: 0;
                margin: auto;
                font-size: 26px;
            }
        }

        .body {
            overflow: hidden;
            padding: 20px 20px 15px;

            .userinfo-yes-login {
                display: flex;
                justify-content: flex-end;
                align-items: center;
                padding: 24px 0;

                .left {
                    width: 180px;
                }

                .right {
                    margin-left: 30px;
                }
            }

            .name {
                color: #fff;
                text-align: right;
                margin-bottom: 15px;
            }

            .info {
                height: 26px;
                display: flex;
                align-items: center;
                justify-content: center;
                background-color: rgba(0, 0, 0, .2);
                border-radius: 13px;
                color: #eee;
                padding: 0 10px;
                font-size: 12px;

                .center {
                    margin: 0 5px;
                }

                .tip {
                    display: flex;
                    align-items: center;
                    flex-direction: row-reverse;

                    .font {
                        font-size: 20px;
                        color: #fbc230;
                        margin-left: 5px;
                    }
                }

            }

            .avatar {
                width: 90px;
                height: 90px;
                margin: 0 auto;
                background-color: rgba(0, 0, 0, .2);
                position: relative;
                // box-shadow: #ffffff6e 0 0 0 10rpx;
                border: 5px solid #ffffff6e;
                border-radius: 50%;
                overflow: hidden;

                .img {
                    display: block;
                    width: 100%;
                    height: 100%;
                }
            }

            .loginBtn {
                margin: 15px auto 0;
                width: 150px;
                height: 36px;
                border-radius: 18px;
                display: flex;
                justify-content: center;
                align-items: center;
                font-size: 14px;
                color: #fff;
                background-color: rgba(0, 0, 0, .2);
            }
        }

        .foot {
            padding: 0 20px;

            .box {
                width: 100%;
                background-color: #fff;
                border-radius: 10px;
                box-shadow: 0 0 14px -14rpx #73849cd3;
                display: flex;
                align-items: center;
                height: 100px;

                .item {
                    width: calc(100% / 3);
                    position: relative;
                    display: flex;
                    flex-direction: column;
                    justify-content: center;
                    align-items: center;

                    &:last-child::after {
                        background-color: transparent;
                    }

                    &::after {
                        content: "";
                        display: block;
                        position: absolute;
                        top: 0;
                        bottom: 0;
                        right: 0;
                        width: 1px;
                        height: 50px;
                        background-color: #80808059;
                    }

                    .icon {
                        width: 34px;

                        .img {
                            display: block;
                            width: 100%;
                        }
                    }

                    .text {
                        color: #333;
                        margin-top: 5px;
                        letter-spacing: -1px;
                    }

                }
            }
        }
    }
</style>